package com.dg.cuckoo.admin.action.projectInfo;

import com.dg.cuckoo.admin.dto.projectInfo.ProViewDto;
import com.dg.cuckoo.admin.service.ProjectOverviewService;
import com.dg.cuckoo.core.BaseController;
import com.dg.cuckoo.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 项目信息-项目概况
 */
@RestController
@RequestMapping("/projectInfo/projectOverview")
public class ProjectOverview extends BaseController {

    @Autowired
    private ProjectOverviewService service;

    /**
     *
     * 新增
     * @param projectId 项目id
     * @param dto 项目概况dto
     * @param features 功能图list
     * @param address 地理位置图list
     * @return
     */
    @PostMapping("save")
    public JsonResult<Void> save(String projectId,ProViewDto dto, MultipartFile[] address,MultipartFile[] features) throws Exception {
        service.save(projectId,dto,address,features);
        return new JsonResult<>(OK);
    }

    /**
     * 通过项目id查询 项目概况
     */
    @PostMapping("byProjectId")
    public JsonResult<String> byProjectId(String projectId){
        String data = service.byProjectId(projectId);
        return new JsonResult<>(OK,data);
    }

    /**
     * 项目信息  用基础资料项目信息的接口
     */

    /**
     * 编辑
     */
    @PostMapping("update")
    public JsonResult<Void> update(ProViewDto dto, MultipartFile[] address, MultipartFile[] features, String projectId) throws Exception {
        service.update(dto,address,features,projectId);
        return new JsonResult<>(OK);
    }

    /**
     * 查看地理位置
     * @param projectId 项目id
     * @return
     */
    @PostMapping("addressInfo")
    public JsonResult<List<String>> addressInfo(String projectId){
        List<String> data = service.address(projectId);
        return new JsonResult<>(OK,data);
    }

}
